﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Light.Framework.Model;
using Castle.ActiveRecord;

namespace Light.Coin.Model
{
    /// <summary>
    /// 积分日志
    /// </summary>
    [ActiveRecord]
    public class CoinLog : Entity
    {

        [BelongsTo("User_ID", Cascade = CascadeEnum.SaveUpdate)]
        public User User
        {
            get;
            set;
        }

        [Property]
        public CoinSource Source
        {
            get;
            set;
        }

        public string SourceDesc
        {
            get
            {
                return Light.Utility.EnumHelper.GetEnumDesc(Source);
            }
        }

        [Property]
        public int Coins
        {
            get;
            set;
        }

        [Property]
        public int Balance
        {
            get;
            set;
        }

        [Property]
        public int SourceID
        {
            get;
            set;
        }

        [Property]
        public string Remark { get; set; }


        protected override void ValidateRules()
        {
            AddValidateRules(Coins != 0, "积分不能为0");
            AddValidateRules(User != null, "用户不能为空");
        }
    }
}
